add_rules("mode.debug", "mode.release")

option("COMPILE_TARGET")
  set_showmenu(true)
  set_description("CPU arch")
  set_default("x86_Linux")
  set_values("x86_Linux","r329_AIPU","riscv64_D1","aarch64_r329","armv7musl_v83x","armv7_Raspberry Pi 32bit,V3S","v83x_v831/v833 AWNN")
option_end()


  if is_config("COMPILE_TARGET","x86_Linux") then
    add_linkdirs("components/asr_lib/lib/x86")
    add_links("ms_asr_x86")
    add_syslinks("asound")
    print("components/asr_lib/lib/x86")

  elseif is_config("COMPILE_TARGET","r329_AIPU") then
    add_linkdirs("components/asr_lib/lib/r329")
    add_links("ms_asr_r329")
    add_syslinks("asound")
    add_ldflags("-Lcomponents/asr_lib/lib/r329", "-laipudrv", {force = true})
    print("components/asr_lib/lib/r329")

  elseif is_config("COMPILE_TARGET","riscv64_D1") then
    add_linkdirs("components/asr_lib/lib/riscv64")
    add_links("ms_asr_riscv64")
    add_syslinks("asound")
    print("components/asr_lib/lib/riscv64")

  elseif is_config("COMPILE_TARGET","aarch64_r329") then
    add_linkdirs("components/asr_lib/lib/aarch64")
    add_links("ms_asr_aarch64","asound")
    print("components/asr_lib/lib/aarch64")

  elseif is_config("COMPILE_TARGET","armv7musl_v83x") then
    add_linkdirs("components/asr_lib/lib/armv7musl")
    add_links("ms_asr_armv7musl","asound")
    print("components/asr_lib/lib/armv7musl")

  elseif is_config("COMPILE_TARGET","armv7_Raspberry Pi 32bit,V3S") then
    add_linkdirs("components/asr_lib/lib/armv7")
    add_links("ms_asr_armv7","asound")
    print("components/asr_lib/lib/armv7")

  elseif is_config("COMPILE_TARGET","v83x_v831/v833 AWNN") then
    add_linkdirs("components/asr_lib/lib/v83x")
    add_links("ms_asr_aarch64","asound")
    print("components/asr_lib/lib/v83x")
end


add_includedirs("components/asr_lib/include","components/utils/include")

target("asr_lib")
    set_kind("static")
    add_files("components/asr_lib/src/*.c")

target("utils")
    set_kind("static")
    add_files("components/utils/src/*.c")


target("maix_asr")
    set_kind("binary")
    add_files("main.cpp")
    add_deps("utils")
    add_deps("asr_lib")
    add_ldflags("-lpthread -ldl")